package com.imooc.controller;

import com.imooc.security.data.pojo.dto.UserResponseDTO;
import com.imooc.security.data.pojo.response.CommonResponseDto;
import com.imooc.security.data.pojo.utils.ResponseUtil;
import com.imooc.security.feign.DataFeign;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Created By Houce
 * @date 2020-07-14 15:43
 */
@RestController
@RequestMapping("/testController")
public class TestController {


    @Resource
    private DataFeign dataFeign;

    @GetMapping("/test1")
    public String test1(){
        System.out.println("=================进入test1方法================");
        System.out.println("=================完成test1方法================");
        return "Hello Spring Security";
    }

    @GetMapping("/userTest")
    public CommonResponseDto<?> queryUserByFeign(@RequestParam("uid")final String uid){
        System.out.println("=================进入 userTest controller方法=================");
        CommonResponseDto<UserResponseDTO> userResponseDTOCommonResponse = dataFeign.queryUserByUid(uid);
        return ResponseUtil.wrapSuccess(userResponseDTOCommonResponse);
    }
}
